import java.lang.reflect.Array;
import java.util.*;

public class Test {
    public static void main(String[] args) {
        List<List<Integer>> List = new ArrayList<>();
        Scanner scanner  = new Scanner(System.in);
        //System.out.println("请输入队伍个数");
        int n = scanner.nextInt();
        List<Integer> list = new ArrayList<>(3);
        for (int i = 0; i < n; i++) {
            //System.out.println("请输入"+i+"号队伍每个队员的水平值");
            for (int j = 0; j < 3; j++) {
                //System.out.println("请输入"+i+"号队伍"+j+"号成员的水平值");
                int a_i = scanner.nextInt();
                list.add(a_i);
            }
            Collections.sort(list);
            List.add(list);
        }
        long max = 0;
        for (int i = 0; i < List.size(); i++) {
           max += List.get(i).get(1);
        }
        System.out.println(max);
    }
}
